/*     */ package com.cr.web.controller.system;
/*     */ 
/*     */ import com.cr.common.annotation.Log;
/*     */ import com.cr.common.core.controller.BaseController;
/*     */ import com.cr.common.core.domain.AjaxResult;
/*     */ import com.cr.common.core.page.TableDataInfo;
/*     */ import com.cr.common.enums.BusinessType;
/*     */ import com.cr.common.utils.poi.ExcelUtil;
/*     */ import com.cr.system.domain.SysConfig;
/*     */ import com.cr.system.service.ISysConfigService;
/*     */ import java.util.List;
/*     */ import org.apache.shiro.authz.annotation.RequiresPermissions;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.ui.ModelMap;
/*     */ import org.springframework.validation.annotation.Validated;
/*     */ import org.springframework.web.bind.annotation.GetMapping;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.PostMapping;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ import org.springframework.web.bind.annotation.ResponseBody;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/system/config"})
/*     */ public class SysConfigController extends BaseController {
/*  33 */   private String prefix = "system/config";
/*     */   
/*     */   @Autowired
/*     */   private ISysConfigService configService;
/*     */   
/*     */   @RequiresPermissions({"system:config:view"})
/*     */   @GetMapping
/*     */   public String config() {
/*  42 */     return this.prefix + "/config";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"system:config:list"})
/*     */   @PostMapping({"/list"})
/*     */   @ResponseBody
/*     */   public TableDataInfo list(SysConfig config) {
/*  53 */     startPage();
/*  54 */     List<SysConfig> list = this.configService.selectConfigList(config);
/*  55 */     return getDataTable(list);
/*     */   }
/*     */   
/*     */   @Log(title = "参数管理", businessType = BusinessType.EXPORT)
/*     */   @RequiresPermissions({"system:config:export"})
/*     */   @PostMapping({"/export"})
/*     */   @ResponseBody
/*     */   public AjaxResult export(SysConfig config) {
/*  64 */     List<SysConfig> list = this.configService.selectConfigList(config);
/*  65 */     ExcelUtil<SysConfig> util = new ExcelUtil(SysConfig.class);
/*  66 */     return util.exportExcel(list, "参数数据");
/*     */   }
/*     */   
/*     */   @GetMapping({"/add"})
/*     */   public String add() {
/*  75 */     return this.prefix + "/add";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"system:config:add"})
/*     */   @Log(title = "参数管理", businessType = BusinessType.INSERT)
/*     */   @PostMapping({"/add"})
/*     */   @ResponseBody
/*     */   public AjaxResult addSave(@Validated SysConfig config) {
/*  87 */     if ("1".equals(this.configService.checkConfigKeyUnique(config)))
/*  89 */       return error("新增参数'" + config.getConfigName() + "'失败，参数键名已存在"); 
/*  91 */     config.setCreateBy(getLoginName());
/*  92 */     return toAjax(this.configService.insertConfig(config));
/*     */   }
/*     */   
/*     */   @GetMapping({"/edit/{configId}"})
/*     */   public String edit(@PathVariable("configId") Long configId, ModelMap mmap) {
/* 101 */     mmap.put("config", this.configService.selectConfigById(configId));
/* 102 */     return this.prefix + "/edit";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"system:config:edit"})
/*     */   @Log(title = "参数管理", businessType = BusinessType.UPDATE)
/*     */   @PostMapping({"/edit"})
/*     */   @ResponseBody
/*     */   public AjaxResult editSave(@Validated SysConfig config) {
/* 114 */     if ("1".equals(this.configService.checkConfigKeyUnique(config)))
/* 116 */       return error("修改参数'" + config.getConfigName() + "'失败，参数键名已存在"); 
/* 118 */     config.setUpdateBy(getLoginName());
/* 119 */     return toAjax(this.configService.updateConfig(config));
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"system:config:remove"})
/*     */   @Log(title = "参数管理", businessType = BusinessType.DELETE)
/*     */   @PostMapping({"/remove"})
/*     */   @ResponseBody
/*     */   public AjaxResult remove(String ids) {
/* 131 */     this.configService.deleteConfigByIds(ids);
/* 132 */     return success();
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"system:config:remove"})
/*     */   @Log(title = "参数管理", businessType = BusinessType.CLEAN)
/*     */   @GetMapping({"/refreshCache"})
/*     */   @ResponseBody
/*     */   public AjaxResult refreshCache() {
/* 144 */     this.configService.resetConfigCache();
/* 145 */     return success();
/*     */   }
/*     */   
/*     */   @PostMapping({"/checkConfigKeyUnique"})
/*     */   @ResponseBody
/*     */   public String checkConfigKeyUnique(SysConfig config) {
/* 155 */     return this.configService.checkConfigKeyUnique(config);
/*     */   }
/*     */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\classes\com.zip!\com\cr\web\controller\system\SysConfigController.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */